#include "UiCarWnd.h"

#ifdef MERGER_APP_TO_SHELL
extern HINSTANCE	g_SDHResModuleHandle;
#endif

UiCarWnd::UiCarWnd()
{
}

UiCarWnd::~UiCarWnd()
{
}

BOOL UiCarWnd::InitUiWin(void)
{
	BOOL bRtn = FALSE;
	LoadiInterItem();
	return bRtn;
}

void UiCarWnd::PaintWin(HDC hdc, RECT* prcWin, RECT* prcUpdate)
{
	m_CarWndBG->Draw(hdc, prcWin, false, false);
}

int UiCarWnd::OnLButtonDown(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonDown(fwKeys, xPos, yPos);
}

int UiCarWnd::OnLButtonUp(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonUp(fwKeys, xPos, yPos);

}

void UiCarWnd::LoadiInterItem()
{
//jdhuang 20120818
#ifndef MERGER_APP_TO_SHELL	
	m_CarWndBG = ImagingHelper::GetImageObject(MzGetInstanceHandle(), 1066);
#else
	m_CarWndBG = ImagingHelper::GetImageObject(g_SDHResModuleHandle, 2066);
#endif
	RECT rtBtnCarWnd[MAX_CAR_WND_BTN] = 
	{
		620, 271, 736, 332, 
		30, 120, 71, 161,
		713, 120, 754, 161,
	};
	
	m_BtnCarWnd[CAR_WND_ENTER].SetPos(rtBtnCarWnd[CAR_WND_ENTER].left, rtBtnCarWnd[CAR_WND_ENTER].top,
					rtBtnCarWnd[CAR_WND_ENTER].right-rtBtnCarWnd[CAR_WND_ENTER].left,
					rtBtnCarWnd[CAR_WND_ENTER].bottom-rtBtnCarWnd[CAR_WND_ENTER].top);
	m_BtnCarWnd[CAR_WND_ENTER].SetID(6400);
#ifndef MERGER_APP_TO_SHELL	
	m_BtnCarWnd[CAR_WND_ENTER].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1004, true));
	m_BtnCarWnd[CAR_WND_ENTER].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1005, true));
#else
	m_BtnCarWnd[CAR_WND_ENTER].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,2004, true));
	m_BtnCarWnd[CAR_WND_ENTER].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,2005, true));
#endif
	m_BtnCarWnd[CAR_WND_ENTER].SetText(L"OK");
	m_BtnCarWnd[CAR_WND_ENTER].SetTextColor(RGB(255, 255, 255));
	AddChild(&m_BtnCarWnd[CAR_WND_ENTER]);

	m_BtnCarWnd[CAR_WND_LAST].SetPos(rtBtnCarWnd[CAR_WND_LAST].left, rtBtnCarWnd[CAR_WND_LAST].top,
					rtBtnCarWnd[CAR_WND_LAST].right-rtBtnCarWnd[CAR_WND_LAST].left,
					rtBtnCarWnd[CAR_WND_LAST].bottom-rtBtnCarWnd[CAR_WND_LAST].top);
	m_BtnCarWnd[CAR_WND_LAST].SetID(6401);
#ifndef MERGER_APP_TO_SHELL	
	m_BtnCarWnd[CAR_WND_LAST].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1014, true));
	m_BtnCarWnd[CAR_WND_LAST].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1015, true));
#else
	m_BtnCarWnd[CAR_WND_LAST].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,2014, true));
	m_BtnCarWnd[CAR_WND_LAST].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,2015, true));
#endif
	AddChild(&m_BtnCarWnd[CAR_WND_LAST]);

	m_BtnCarWnd[CAR_WND_NEXT].SetPos(rtBtnCarWnd[CAR_WND_NEXT].left, rtBtnCarWnd[CAR_WND_NEXT].top,
					rtBtnCarWnd[CAR_WND_NEXT].right-rtBtnCarWnd[CAR_WND_NEXT].left,
					rtBtnCarWnd[CAR_WND_NEXT].bottom-rtBtnCarWnd[CAR_WND_NEXT].top);
	m_BtnCarWnd[CAR_WND_NEXT].SetID(6402);
#ifndef MERGER_APP_TO_SHELL	
	m_BtnCarWnd[CAR_WND_NEXT].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1016, true));
	m_BtnCarWnd[CAR_WND_NEXT].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1017, true));
#else
	m_BtnCarWnd[CAR_WND_NEXT].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,2016, true));
	m_BtnCarWnd[CAR_WND_NEXT].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,2017, true));
#endif
	AddChild(&m_BtnCarWnd[CAR_WND_NEXT]);

}

BOOL UiCarWnd::InitImages()
{
	return TRUE;
}
void UiCarWnd::DeleteImages()
{
	m_CarWndBG->UnloadImage();
}